/*   
 * Copyright 2011-2012 the original author or authors.   
 *   
 * Licensed under the Apache License, Version 2.0 (the "License");   
 * you may not use this file except in compliance with the License.   
 * You may obtain a copy of the License at   
 *   
 *      http://www.apache.org/licenses/LICENSE-2.0   
 *   
 * Unless required by applicable law or agreed to in writing, software   
 * distributed under the License is distributed on an "AS IS" BASIS,   
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   
 * See the License for the specific language governing permissions and   
 * limitations under the License.   
 */
package code.google.com.p.antigovframe.sample.integration

/**
 * @author Jacob Lee
 * @since 2012. 7. 17.
 * 
 */ 
 
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.test.context.ContextConfiguration
import org.springframework.transaction.annotation.Transactional
import org.unitils.dbunit.annotation.DataSet
import spock.lang.*
import spock.unitils.UnitilsSupport
import javax.annotation.Resource
import org.springframework.jdbc.core.simple.SimpleJdbcTemplate
import org.springframework.jdbc.core.simple.ParameterizedRowMapper
import java.sql.ResultSet
import groovy.sql.Sql
import spock.lang.Unroll


import code.google.com.p.antigovframe.sample.dao.TaskDAO;
import code.google.com.p.antigovframe.sample.domain.Task;



@ContextConfiguration(locations = ["classpath:servlet-context.xml"])
@UnitilsSupport
@DataSet
class TaskDAOSpec extends spock.lang.Specification {
 
  private static final String SELECT_ALL_FROM_Task =
'''select id as "id", name as "name", description as "description"
from Task'''

  @Autowired
  private TaskDAO dao

  @Transactional
  def "finds a Task by name"() {
    setup:
    def TaskName = 'BPH'

    when:
    Task Task = dao.findByNo(TaskName)

    then:
    Task.title =="Bank BPH"
	 
  }
  
  // Groovy mixin to not pollute production classes with test-specific stuff
  @Category(Task)
  class TaskExtensions {
	boolean equals(Object other) {
	  return (this.id == other.id) && (this.taskNo == other.taskNo) &&
			  (this.title == other.title)
	}
  }

}
